<div class="row">
    <p id="list-title">{{.PageName}}</p>
</div>

<form id="stockLocationForm" action="{{.URL}}{{.RecordID}}?action={{.Action}}" method="post" class="post-form form-horizontal {{if .Readonly}}form-disabled{{else}}form-edit{{end}}" role="form">
    <div class="row title-action">
        {{if .RecordID}} {{if .Readonly}}
        <a href="{{.URL}}{{.RecordID}}?action=edit" class="btn btn-success fa fa-pencil pull-left form-edit-btn">&nbsp编辑</a>
        <a href="{{.URL}}?action=create" type="buttom" class="btn btn-success fa fa-plus pull-left form-create-btn">&nbsp新建</a>{{end}}{{end}}
        <button type="submit" form="stockLocationForm" class="btn btn-primary fa fa-save pull-left form-save-btn">&nbsp保存</button> {{if .Readonly}}
        <button type="button" class="btn btn-danger fa fa-remove  pull-left form-cancel-btn">&nbsp取消</button> {{else}}
        <a href="{{.URL}}" class="btn btn-danger fa fa-remove  pull-left">&nbsp取消</a> {{end}}
        <a href="{{.URL}}" class="btn btn-info fa fa-list pull-left">&nbsp列表</a>
    </div>
    {{ .xsrf }} {{if .RecordID}}
    <input type="hidden" data-type="int" class="{{.FormField}}" name="recordID" id="record-id" value="{{.RecordID}}"> {{end}}

    <div class="row">
        <div class="col-md-6">
            <fieldset>
                <legend>基本信息</legend>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="name" class="col-md-4 control-label label-start">库位名称<span class="required-input">&nbsp*</span></label>
                            <div class="col-md-8">
                                <p class="p-form-control">{{if .Location}} {{.Location.Name}} {{end}}</p>
                                <input data-type="string" class="{{.FormField}} form-control" name="Name" type="text" {{if .Location}} value="{{.Location.Name}}" {{end}} />
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="compay" class="col-md-4 control-label label-start">所属公司<span class="required-input">&nbsp*</span></label>
                            <div class="col-md-8">
                                <p class="p-form-control"> {{if and .Location .Location.Company}} {{.Location.Company.Name}}{{end}}</p>
                                <select data-type="int" name="Company" id="compay" class="{{.FormField}} form-control select-company">
                                    {{if and .Location .Location.Company}}
                                    <option value="{{.Location.Company.ID}}" selected="selected">{{.Location.Company.Name}}</option>
                                    {{end}} 
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="Barcode" class="col-md-4 control-label label-start">库位编码</label>
                            <div class="col-md-8">
                                <p class="p-form-control">{{if .Location}} {{.Location.Barcode}} {{end}}</p>
                                <input data-type="string" class="{{.FormField}} form-control" name="Barcode" type="text" {{if .Location}} value="{{.Location.Barcode}}" {{end}} />
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="Parent" class="col-md-4 control-label label-start">上级库位</label>
                            <div class="col-md-8">
                                <p class="p-form-control"> {{if and .Location .Location.Parent}} {{.Location.Parent.Name}}{{end}}</p>
                                <select data-type="int" name="Parent" id="Parent" class="{{.FormField}} form-control select-stock-location">
                             {{if and .Location .Location.Parent}}
                            <option value="{{.Location.Parent.ID}}" selected="selected">{{.Location.Parent.Name}}</option>
                             {{end}} 
                        </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="Usage" class="col-md-4 control-label label-start">库位类型<span class="required-input">&nbsp*</span></label>
                            <div class="col-md-8">
                                <p class="p-form-control"> {{if .Location}} {{.Location.Usage}}{{end}}</p>
                                <select data-type="string" name="Usage" id="Usage" class="{{.FormField}} form-control select-stock-location-usage">
                             {{if .Location}} 
                            <option value="{{.Location.Usage}}" selected="selected">{{.Location.Usage}}</option>
                            {{else}}<option value="internal" selected="selected">内部库位</option>{{end}} 
                        </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="active" class="col-md-4 control-label ">有效</label>
                            <div class="col-md-8 ">
                                <input data-type="bool" name="Active" id="active" class="form-control form-checkbox {{.FormField}}" {{if and .Location .Location.Active}} {{if eq .Location.Active true }}data-oldValue="{{.Location.Active}}" {{end}}{{else}} checked="checked" {{end}} type="checkbox">
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
        <div class="col-md-6">
            <fieldset>
                <legend>其他信息</legend>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="ReturnLocation" class="col-md-4 control-label ">退货库位</label>
                            <div class="col-md-8 ">
                                <input data-type="bool" name="ReturnLocation" {{if .StockLocation}} data-oldvalue="{{.StockLocation.ReturnLocation}}" {{if eq .StockLocation.ReturnLocation true}}checked="checked" {{end}} {{end}} id="ReturnLocation" class="form-control form-checkbox {{.FormField}}"
                                    type="checkbox">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="ScrapLocation" class="col-md-4 control-label ">废料库位</label>
                            <div class="col-md-8 ">
                                <input data-type="bool" name="ScrapLocation" {{if .StockLocation}} data-oldvalue="{{.StockLocation.ReturnLocation}}" {{if eq .StockLocation.ScrapLocation true}}checked="checked" {{end}}{{end}} id="ScrapLocation" class="form-control form-checkbox {{.FormField}}"
                                    type="checkbox">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="Posx" class="col-md-4 control-label label-start">通道(X)</label>
                            <div class="col-md-8">
                                <p class="p-form-control">{{if .Location}} {{.Location.Posx}} {{end}}</p>
                                <input data-type="int" class="{{.FormField}} form-control" name="Posx" type="text" {{if .Location}} value="{{.Location.Posx}}" {{end}} />
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="Posy" class="col-md-4 control-label label-start">货架(Y)</label>
                            <div class="col-md-8">
                                <p class="p-form-control">{{if .Location}} {{.Location.Posy}} {{end}}</p>
                                <input data-type="int" class="{{.FormField}} form-control" name="Posy" type="text" {{if .Location}} value="{{.Location.Posy}}" {{end}} />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="Posz" class="col-md-4 control-label label-start">层</label>
                            <div class="col-md-8">
                                <p class="p-form-control">{{if .Location}} {{.Location.Posz}} {{end}}</p>
                                <input data-type="int" class="{{.FormField}} form-control" name="Posz" type="text" {{if .Location}} value="{{.Location.Posz}}" {{end}} />
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
    </div>

</form>